<?php
  class Plugins_Upload extends model {
  
  
  
  function getformadd($productid="")
  {
  

  

  
  
  $str='<div class="uploadclass" style="width:640px;height:360px">uploadfile<div class="areafile" style="width:640px;height:360px"></div><div><input type="text" name="detail[]"></div></div>';
  
  $str='<div class="wrpPlg clBg5 clBd2 bdFull">
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="ico icoUlPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="txtAtcPlg fs03">Upload</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                        <div class="addTool">
                            <div title="Remove" class="btnIco btnRmvTl deletebutton">
                                <span class="ico icoRmvTl"></span>
                            </div>
                        </div>
                    </div>
                    <form class="frmUlPlg">
                        <input type="text" placeholder="Type title here." class="inpAddCtntNoBd w616 boldGen clTxt2 fs04 clBg5">
                        <div class="wrpUlArea">
                            <div class="cloudAdd areafile">
                                <span class="ico2 icoCloudAdd"></span>
                                <div class="btnIco upAddIco">
                                    <span class=" ico2 icoUpAdd"></span>
                                    <div class="wrpUlFile">
                                        
                                    </div>
                                </div>
                                <div class="ulPg clTxtW fs09" style="display:none">99<span>%</span></div>
                                <span style="display:none" class="ico2 icoCrtGrn"></span>
                            </div>
                            <div class="ulDesNameSize clTxt3 fs03">
                                <span class="desUl">Click Cloud for Upload File</span>
                                <span class="fileName"></span><br>
                                <span class="fileSize"></span>
                            </div>
                        </div>
                        <textarea name="detail[]" placeholder="Type text here to explain this file." class="inpAddCtntNoBd w616 clTxt2 fs03 clBg5"></textarea>
                    </form>
                </div>';
  
  
  
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
 // $arraydata['js'][]=pluginjsinfo.'/upload.js';


  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
  
  function getformlanding($arraydata)
  {
$code="";
if($arraydata['file']['filename'])
{
$code = '<div class="ldIt wrpDlLd clBg4">';
$code .= '<h2 class="clTxt2 fs04">Download Menu</h2>';
$code .= '<div class="wrpInDlLd">';
$code.= '<div class="btnIco dlLd">';
$code.= '<abbr title="Download">';
$code.= '<span class="ico2 icoDlLd"></span>';
$code.= '</abbr>';
$code.= '</div>';
$code.= '<a href="'.$arraydata['file']['newpath'].'" target="_blank">';
$code.= '<div class="desFileDlLd">';
$code.= '<span class="fileName">'.$arraydata['file']['filename'].'</span><br>';
$code.= '<span class="fileSize">'.$arraydata['file']['size'].' kb</span>';
$code.= '</div>';
$code.= '</a>';
$code.= '</div>';
$code.= '<div class="desDlLd">';
$code.= '<p>'.$arraydata['detail'].'</p>';
$code.= '</div>';
$code.= '</div>';
}
$data['str']=$code;
$data['target']='secondtarget';

return $data;
  
  
  }
  
  function getplugin($plugreid)
  {
  
  $sql="select * from tb_plugins_upload where plugreid=".$plugreid;
  $arrayplugin=$this->db->db_set_1recordrow($sql);
  $arrayplugin['file']=array();
  
  if($arrayplugin['fileid'])
  {
  $sql="select (CONCAT('". baseinfo . "','/', path)) as newpath,filename,name,tb_file.size from tb_file where fileid=".$arrayplugin['fileid'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  $arrayplugin['file']=$arrayfile;
  list($nameset,$exty)=explode(".",$arrayfile['name']);
  $arrayplugin['type']=$exty;
  }else
  {
  $arrayplugin['type']='';
  }
  
  
  
  
  return $arrayplugin;
  

  
  
  

  
  }
  
  function saveplugin($arraydata,$productid,$plugreid)
  {
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  $arraydata['detail']=$arraydata['detail'];
  if($arraydata['fileid'])
  {
  $sql="select path,productid,name from tb_file where fileid=".$arraydata['fileid'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  if($arrayfile['productid']==0)
  { 
     $newpath=filepath.'/'.$productid.'/'.$arrayfile['name']   ;
     if(copy($arrayfile['path'],$newpath))
     {
     @chmod($newpath,0777);
     unlink($arrayfile['path']);
     $arrayfile['cache']=0;
     $arrayfile['path']=str_replace(rootpath.'/','',$newpath);
     $arrayfile['productid']=$productid;
     $this->db->db_set($arrayfile,'tb_file',' fileid='.$arraydata['fileid']);
     
     
     }
     
     
  
  }
  }
  
  $this->db->db_set($arraydata,'tb_plugins_upload');
  
  }
  
  
  }
?>
